package day9;
import java.io.*;
/**
 * @author oldliu
 * @since 1.0
 */
public class TestI {
    public static String intToIp(int id) {
        String ip="";
        try {
            ByteArrayOutputStream boutput = new ByteArrayOutputStream();
            DataOutputStream doutput = new DataOutputStream(boutput);
            doutput.writeInt(id);
            byte[] buf = boutput.toByteArray();
            doutput.close();

            for(int i=0;i<buf.length;i++){
                byte b=buf[i];
                System.out.println(0XFF&b);
               ip+=String.valueOf(0XFF&b);
               if(i<buf.length-1)
                   ip+=".";
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return ip;

    }

    public static int findNumber(int[] n) {
        int count=0;
        for(int i=0;i<n.length-1;i++){
            for(int j=i;j<n.length-1;j++){
                if(n[i]!=n[j]){
                    int temp=n[i];
                    n[i]=n[j];
                    n[j]=temp;
                    count++;
                }

            }
        }
        return count;

    }
}
